{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import torch\n",
    "import torch.nn as nn\n",
    "import torch.nn.functional as func\n",
    "\n",
    "class LogisticModel(nn.Module):\n",
    "    def __init__(self, in_dim, out_dim):\n",
    "        super(LogisticModel, self).__init__()\n",
    "        self.linear = nn.Linear(in_dim, out_dim)\n",
    "        \n",
    "    def forward(self,x):\n",
    "        out = func.sigmoid(self.linear(x))\n",
    "        return out\n",
    "in_dim, out_dim =1,1    \n",
    "model = LogisticModel(1, 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "criterion = torch.nn.BCELoss(size_average=True)\n",
    "optimiser =  torch.optim.SGD(model.parameters(), lr =0.01)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "x_train = torch.tensor([[1.6],[2.1],[1.3],[4.8],[3.5]], dtype=torch.float).reshape(-1,1)\n",
    "y_train = torch.tensor([[0],[0],[0],[1],[1]], dtype=torch.float).reshape(-1,1) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch0, loss 1.6305288076400757\n",
      "epoch1, loss 1.6069027185440063\n",
      "epoch2, loss 1.5834498405456543\n",
      "epoch3, loss 1.5601754188537598\n",
      "epoch4, loss 1.5370850563049316\n",
      "epoch5, loss 1.5141843557357788\n",
      "epoch6, loss 1.4914792776107788\n",
      "epoch7, loss 1.4689756631851196\n",
      "epoch8, loss 1.4466791152954102\n",
      "epoch9, loss 1.4245960712432861\n",
      "epoch10, loss 1.4027328491210938\n",
      "epoch11, loss 1.3810956478118896\n",
      "epoch12, loss 1.35969078540802\n",
      "epoch13, loss 1.3385248184204102\n",
      "epoch14, loss 1.3176043033599854\n",
      "epoch15, loss 1.2969356775283813\n",
      "epoch16, loss 1.2765257358551025\n",
      "epoch17, loss 1.2563809156417847\n",
      "epoch18, loss 1.2365080118179321\n",
      "epoch19, loss 1.2169134616851807\n",
      "epoch20, loss 1.197603702545166\n",
      "epoch21, loss 1.178585410118103\n",
      "epoch22, loss 1.1598647832870483\n",
      "epoch23, loss 1.1414480209350586\n",
      "epoch24, loss 1.1233413219451904\n",
      "epoch25, loss 1.1055504083633423\n",
      "epoch26, loss 1.0880807638168335\n",
      "epoch27, loss 1.0709381103515625\n",
      "epoch28, loss 1.0541274547576904\n",
      "epoch29, loss 1.0376534461975098\n",
      "epoch30, loss 1.0215208530426025\n",
      "epoch31, loss 1.0057333707809448\n",
      "epoch32, loss 0.9902949333190918\n",
      "epoch33, loss 0.9752086400985718\n",
      "epoch34, loss 0.9604774713516235\n",
      "epoch35, loss 0.9461036920547485\n",
      "epoch36, loss 0.9320888519287109\n",
      "epoch37, loss 0.9184344410896301\n",
      "epoch38, loss 0.9051411747932434\n",
      "epoch39, loss 0.8922092318534851\n",
      "epoch40, loss 0.8796381950378418\n",
      "epoch41, loss 0.8674271702766418\n",
      "epoch42, loss 0.8555746078491211\n",
      "epoch43, loss 0.844078540802002\n",
      "epoch44, loss 0.8329364061355591\n",
      "epoch45, loss 0.8221448063850403\n",
      "epoch46, loss 0.8117003440856934\n",
      "epoch47, loss 0.8015987277030945\n",
      "epoch48, loss 0.7918353080749512\n",
      "epoch49, loss 0.7824050188064575\n",
      "epoch50, loss 0.7733023166656494\n",
      "epoch51, loss 0.7645212411880493\n",
      "epoch52, loss 0.7560555934906006\n",
      "epoch53, loss 0.7478986978530884\n",
      "epoch54, loss 0.7400437593460083\n",
      "epoch55, loss 0.7324833869934082\n",
      "epoch56, loss 0.7252104878425598\n",
      "epoch57, loss 0.7182171940803528\n",
      "epoch58, loss 0.7114959955215454\n",
      "epoch59, loss 0.7050390839576721\n",
      "epoch60, loss 0.6988384127616882\n",
      "epoch61, loss 0.6928861141204834\n",
      "epoch62, loss 0.6871742010116577\n",
      "epoch63, loss 0.681694746017456\n",
      "epoch64, loss 0.676439642906189\n",
      "epoch65, loss 0.6714012026786804\n",
      "epoch66, loss 0.6665716171264648\n",
      "epoch67, loss 0.6619430780410767\n",
      "epoch68, loss 0.6575080752372742\n",
      "epoch69, loss 0.6532592177391052\n",
      "epoch70, loss 0.6491891741752625\n",
      "epoch71, loss 0.6452909111976624\n",
      "epoch72, loss 0.6415573358535767\n",
      "epoch73, loss 0.6379817724227905\n",
      "epoch74, loss 0.6345576047897339\n",
      "epoch75, loss 0.6312784552574158\n",
      "epoch76, loss 0.6281381845474243\n",
      "epoch77, loss 0.6251307129859924\n",
      "epoch78, loss 0.6222503781318665\n",
      "epoch79, loss 0.6194913387298584\n",
      "epoch80, loss 0.6168484687805176\n",
      "epoch81, loss 0.6143164038658142\n",
      "epoch82, loss 0.6118903160095215\n",
      "epoch83, loss 0.6095653176307678\n",
      "epoch84, loss 0.607336699962616\n",
      "epoch85, loss 0.6052001118659973\n",
      "epoch86, loss 0.6031513214111328\n",
      "epoch87, loss 0.6011863350868225\n",
      "epoch88, loss 0.5993011593818665\n",
      "epoch89, loss 0.5974920392036438\n",
      "epoch90, loss 0.5957554578781128\n",
      "epoch91, loss 0.5940880179405212\n",
      "epoch92, loss 0.5924865007400513\n",
      "epoch93, loss 0.5909477472305298\n",
      "epoch94, loss 0.589468777179718\n",
      "epoch95, loss 0.5880467891693115\n",
      "epoch96, loss 0.5866791009902954\n",
      "epoch97, loss 0.5853630304336548\n",
      "epoch98, loss 0.5840962529182434\n",
      "epoch99, loss 0.5828763246536255\n",
      "epoch100, loss 0.5817010998725891\n",
      "epoch101, loss 0.5805683732032776\n",
      "epoch102, loss 0.5794761180877686\n",
      "epoch103, loss 0.5784226059913635\n",
      "epoch104, loss 0.5774057507514954\n",
      "epoch105, loss 0.5764238834381104\n",
      "epoch106, loss 0.5754753351211548\n",
      "epoch107, loss 0.5745586156845093\n",
      "epoch108, loss 0.5736719965934753\n",
      "epoch109, loss 0.5728142857551575\n",
      "epoch110, loss 0.5719839930534363\n",
      "epoch111, loss 0.5711798667907715\n",
      "epoch112, loss 0.5704006552696228\n",
      "epoch113, loss 0.5696450471878052\n",
      "epoch114, loss 0.568912148475647\n",
      "epoch115, loss 0.5682008266448975\n",
      "epoch116, loss 0.5675100088119507\n",
      "epoch117, loss 0.5668387413024902\n",
      "epoch118, loss 0.5661860704421997\n",
      "epoch119, loss 0.5655513405799866\n",
      "epoch120, loss 0.5649334192276001\n",
      "epoch121, loss 0.5643316507339478\n",
      "epoch122, loss 0.5637452602386475\n",
      "epoch123, loss 0.5631736516952515\n",
      "epoch124, loss 0.5626159906387329\n",
      "epoch125, loss 0.562071681022644\n",
      "epoch126, loss 0.5615400671958923\n",
      "epoch127, loss 0.5610207319259644\n",
      "epoch128, loss 0.5605128407478333\n",
      "epoch129, loss 0.5600160956382751\n",
      "epoch130, loss 0.5595299005508423\n",
      "epoch131, loss 0.5590537786483765\n",
      "epoch132, loss 0.5585871934890747\n",
      "epoch133, loss 0.5581299066543579\n",
      "epoch134, loss 0.5576813220977783\n",
      "epoch135, loss 0.5572410821914673\n",
      "epoch136, loss 0.5568088293075562\n",
      "epoch137, loss 0.5563842058181763\n",
      "epoch138, loss 0.555966854095459\n",
      "epoch139, loss 0.5555564761161804\n",
      "epoch140, loss 0.5551527738571167\n",
      "epoch141, loss 0.5547553896903992\n",
      "epoch142, loss 0.5543640851974487\n",
      "epoch143, loss 0.5539785623550415\n",
      "epoch144, loss 0.5535985827445984\n",
      "epoch145, loss 0.5532239079475403\n",
      "epoch146, loss 0.5528542995452881\n",
      "epoch147, loss 0.5524895787239075\n",
      "epoch148, loss 0.5521293878555298\n",
      "epoch149, loss 0.551773726940155\n",
      "epoch150, loss 0.5514222383499146\n",
      "epoch151, loss 0.5510748624801636\n",
      "epoch152, loss 0.550731360912323\n",
      "epoch153, loss 0.5503915548324585\n",
      "epoch154, loss 0.5500553846359253\n",
      "epoch155, loss 0.5497225522994995\n",
      "epoch156, loss 0.5493930578231812\n",
      "epoch157, loss 0.5490666031837463\n",
      "epoch158, loss 0.5487431287765503\n",
      "epoch159, loss 0.5484225749969482\n",
      "epoch160, loss 0.5481048822402954\n",
      "epoch161, loss 0.5477896928787231\n",
      "epoch162, loss 0.5474770665168762\n",
      "epoch163, loss 0.5471668839454651\n",
      "epoch164, loss 0.5468589067459106\n",
      "epoch165, loss 0.5465532541275024\n",
      "epoch166, loss 0.5462497472763062\n",
      "epoch167, loss 0.545948326587677\n",
      "epoch168, loss 0.5456488132476807\n",
      "epoch169, loss 0.5453512072563171\n",
      "epoch170, loss 0.5450555086135864\n",
      "epoch171, loss 0.5447614192962646\n",
      "epoch172, loss 0.5444691181182861\n",
      "epoch173, loss 0.5441783666610718\n",
      "epoch174, loss 0.5438891649246216\n",
      "epoch175, loss 0.5436014533042908\n",
      "epoch176, loss 0.5433152914047241\n",
      "epoch177, loss 0.5430303812026978\n",
      "epoch178, loss 0.542746901512146\n",
      "epoch179, loss 0.5424646139144897\n",
      "epoch180, loss 0.5421836376190186\n",
      "epoch181, loss 0.5419037938117981\n",
      "epoch182, loss 0.5416251420974731\n",
      "epoch183, loss 0.5413476228713989\n",
      "epoch184, loss 0.5410711169242859\n",
      "epoch185, loss 0.5407955646514893\n",
      "epoch186, loss 0.5405211448669434\n",
      "epoch187, loss 0.5402475595474243\n",
      "epoch188, loss 0.5399750471115112\n",
      "epoch189, loss 0.5397032499313354\n",
      "epoch190, loss 0.5394324660301208\n",
      "epoch191, loss 0.5391624569892883\n",
      "epoch192, loss 0.5388932824134827\n",
      "epoch193, loss 0.5386248826980591\n",
      "epoch194, loss 0.5383572578430176\n",
      "epoch195, loss 0.5380903482437134\n",
      "epoch196, loss 0.5378241539001465\n",
      "epoch197, loss 0.5375585556030273\n",
      "epoch198, loss 0.5372937321662903\n",
      "epoch199, loss 0.5370295643806458\n",
      "epoch200, loss 0.536765992641449\n",
      "epoch201, loss 0.5365029573440552\n",
      "epoch202, loss 0.5362406373023987\n",
      "epoch203, loss 0.5359788537025452\n",
      "epoch204, loss 0.5357176065444946\n",
      "epoch205, loss 0.5354569554328918\n",
      "epoch206, loss 0.535196840763092\n",
      "epoch207, loss 0.5349371433258057\n",
      "epoch208, loss 0.5346779227256775\n",
      "epoch209, loss 0.5344193577766418\n",
      "epoch210, loss 0.5341611504554749\n",
      "epoch211, loss 0.5339034795761108\n",
      "epoch212, loss 0.5336462259292603\n",
      "epoch213, loss 0.5333894491195679\n",
      "epoch214, loss 0.5331330299377441\n",
      "epoch215, loss 0.5328770279884338\n",
      "epoch216, loss 0.5326215624809265\n",
      "epoch217, loss 0.5323663949966431\n",
      "epoch218, loss 0.532111644744873\n",
      "epoch219, loss 0.5318573713302612\n",
      "epoch220, loss 0.5316034555435181\n",
      "epoch221, loss 0.531349778175354\n",
      "epoch222, loss 0.5310965776443481\n",
      "epoch223, loss 0.5308437347412109\n",
      "epoch224, loss 0.5305912494659424\n",
      "epoch225, loss 0.5303390622138977\n",
      "epoch226, loss 0.5300872325897217\n",
      "epoch227, loss 0.5298357605934143\n",
      "epoch228, loss 0.529584527015686\n",
      "epoch229, loss 0.5293337106704712\n",
      "epoch230, loss 0.529083251953125\n",
      "epoch231, loss 0.5288329720497131\n",
      "epoch232, loss 0.5285830497741699\n",
      "epoch233, loss 0.5283334851264954\n",
      "epoch234, loss 0.5280841588973999\n",
      "epoch235, loss 0.5278351902961731\n",
      "epoch236, loss 0.5275864005088806\n",
      "epoch237, loss 0.5273379683494568\n",
      "epoch238, loss 0.5270899534225464\n",
      "epoch239, loss 0.5268419981002808\n",
      "epoch240, loss 0.5265944004058838\n",
      "epoch241, loss 0.5263470411300659\n",
      "epoch242, loss 0.5261000394821167\n",
      "epoch243, loss 0.5258532762527466\n",
      "epoch244, loss 0.5256067514419556\n",
      "epoch245, loss 0.5253604650497437\n",
      "epoch246, loss 0.5251144170761108\n",
      "epoch247, loss 0.5248687267303467\n",
      "epoch248, loss 0.5246232151985168\n",
      "epoch249, loss 0.5243780016899109\n",
      "epoch250, loss 0.524133026599884\n",
      "epoch251, loss 0.5238882303237915\n",
      "epoch252, loss 0.5236437320709229\n",
      "epoch253, loss 0.5233994722366333\n",
      "epoch254, loss 0.5231554508209229\n",
      "epoch255, loss 0.5229116678237915\n",
      "epoch256, loss 0.522668182849884\n",
      "epoch257, loss 0.5224248766899109\n",
      "epoch258, loss 0.5221817493438721\n",
      "epoch259, loss 0.5219389200210571\n",
      "epoch260, loss 0.5216963291168213\n",
      "epoch261, loss 0.5214539170265198\n",
      "epoch262, loss 0.5212117433547974\n",
      "epoch263, loss 0.5209698677062988\n",
      "epoch264, loss 0.5207282304763794\n",
      "epoch265, loss 0.5204867124557495\n",
      "epoch266, loss 0.5202454328536987\n",
      "epoch267, loss 0.520004391670227\n",
      "epoch268, loss 0.5197635889053345\n",
      "epoch269, loss 0.519523024559021\n",
      "epoch270, loss 0.5192826390266418\n",
      "epoch271, loss 0.519042432308197\n",
      "epoch272, loss 0.5188025236129761\n",
      "epoch273, loss 0.5185627937316895\n",
      "epoch274, loss 0.5183233022689819\n",
      "epoch275, loss 0.518083930015564\n",
      "epoch276, loss 0.5178449153900146\n",
      "epoch277, loss 0.5176059007644653\n",
      "epoch278, loss 0.5173673629760742\n",
      "epoch279, loss 0.5171288251876831\n",
      "epoch280, loss 0.5168906450271606\n",
      "epoch281, loss 0.5166525840759277\n",
      "epoch282, loss 0.5164147615432739\n",
      "epoch283, loss 0.5161770582199097\n",
      "epoch284, loss 0.5159396529197693\n",
      "epoch285, loss 0.515702486038208\n",
      "epoch286, loss 0.515465497970581\n",
      "epoch287, loss 0.5152286887168884\n",
      "epoch288, loss 0.5149921178817749\n",
      "epoch289, loss 0.5147556662559509\n",
      "epoch290, loss 0.5145195126533508\n",
      "epoch291, loss 0.5142835378646851\n",
      "epoch292, loss 0.5140476822853088\n",
      "epoch293, loss 0.5138121843338013\n",
      "epoch294, loss 0.5135768055915833\n",
      "epoch295, loss 0.5133415460586548\n",
      "epoch296, loss 0.5131065845489502\n",
      "epoch297, loss 0.5128718018531799\n",
      "epoch298, loss 0.512637197971344\n",
      "epoch299, loss 0.5124028325080872\n",
      "epoch300, loss 0.5121685862541199\n",
      "epoch301, loss 0.5119346380233765\n",
      "epoch302, loss 0.5117007493972778\n",
      "epoch303, loss 0.5114671587944031\n",
      "epoch304, loss 0.5112337470054626\n",
      "epoch305, loss 0.5110005140304565\n",
      "epoch306, loss 0.5107675790786743\n",
      "epoch307, loss 0.5105347037315369\n",
      "epoch308, loss 0.5103021264076233\n",
      "epoch309, loss 0.5100696682929993\n",
      "epoch310, loss 0.5098374485969543\n",
      "epoch311, loss 0.5096054077148438\n",
      "epoch312, loss 0.5093735456466675\n",
      "epoch313, loss 0.5091418623924255\n",
      "epoch314, loss 0.5089103579521179\n",
      "epoch315, loss 0.5086791515350342\n",
      "epoch316, loss 0.5084480047225952\n",
      "epoch317, loss 0.5082172155380249\n",
      "epoch318, loss 0.5079864859580994\n",
      "epoch319, loss 0.5077559947967529\n",
      "epoch320, loss 0.5075256824493408\n",
      "epoch321, loss 0.507295548915863\n",
      "epoch322, loss 0.5070656538009644\n",
      "epoch323, loss 0.5068358182907104\n",
      "epoch324, loss 0.50660640001297\n",
      "epoch325, loss 0.5063770413398743\n",
      "epoch326, loss 0.5061477422714233\n",
      "epoch327, loss 0.5059188008308411\n",
      "epoch328, loss 0.5056900382041931\n",
      "epoch329, loss 0.5054613947868347\n",
      "epoch330, loss 0.5052329897880554\n",
      "epoch331, loss 0.5050047636032104\n",
      "epoch332, loss 0.5047767758369446\n",
      "epoch333, loss 0.5045489072799683\n",
      "epoch334, loss 0.5043212175369263\n",
      "epoch335, loss 0.5040937662124634\n",
      "epoch336, loss 0.50386643409729\n",
      "epoch337, loss 0.5036393404006958\n",
      "epoch338, loss 0.5034124255180359\n",
      "epoch339, loss 0.5031856894493103\n",
      "epoch340, loss 0.502959132194519\n",
      "epoch341, loss 0.5027328133583069\n",
      "epoch342, loss 0.5025066137313843\n",
      "epoch343, loss 0.502280592918396\n",
      "epoch344, loss 0.5020548701286316\n",
      "epoch345, loss 0.501829206943512\n",
      "epoch346, loss 0.5016037225723267\n",
      "epoch347, loss 0.5013785362243652\n",
      "epoch348, loss 0.5011534690856934\n",
      "epoch349, loss 0.500928521156311\n",
      "epoch350, loss 0.5007039308547974\n",
      "epoch351, loss 0.5004794001579285\n",
      "epoch352, loss 0.5002549886703491\n",
      "epoch353, loss 0.5000308752059937\n",
      "epoch354, loss 0.4998069405555725\n",
      "epoch355, loss 0.4995831847190857\n",
      "epoch356, loss 0.4993595480918884\n",
      "epoch357, loss 0.4991361200809479\n",
      "epoch358, loss 0.49891287088394165\n",
      "epoch359, loss 0.49868983030319214\n",
      "epoch360, loss 0.4984669089317322\n",
      "epoch361, loss 0.4982442855834961\n",
      "epoch362, loss 0.49802178144454956\n",
      "epoch363, loss 0.49779945611953735\n",
      "epoch364, loss 0.4975772798061371\n",
      "epoch365, loss 0.4973553717136383\n",
      "epoch366, loss 0.4971335828304291\n",
      "epoch367, loss 0.49691200256347656\n",
      "epoch368, loss 0.4966905117034912\n",
      "epoch369, loss 0.49646925926208496\n",
      "epoch370, loss 0.4962482452392578\n",
      "epoch371, loss 0.4960273206233978\n",
      "epoch372, loss 0.49580663442611694\n",
      "epoch373, loss 0.495586097240448\n",
      "epoch374, loss 0.49536576867103577\n",
      "epoch375, loss 0.49514561891555786\n",
      "epoch376, loss 0.4949255883693695\n",
      "epoch377, loss 0.49470585584640503\n",
      "epoch378, loss 0.4944861829280853\n",
      "epoch379, loss 0.4942667484283447\n",
      "epoch380, loss 0.49404749274253845\n",
      "epoch381, loss 0.4938283860683441\n",
      "epoch382, loss 0.4936094284057617\n",
      "epoch383, loss 0.4933907091617584\n",
      "epoch384, loss 0.4931721091270447\n",
      "epoch385, loss 0.49295371770858765\n",
      "epoch386, loss 0.49273553490638733\n",
      "epoch387, loss 0.49251753091812134\n",
      "epoch388, loss 0.4922997057437897\n",
      "epoch389, loss 0.4920819401741028\n",
      "epoch390, loss 0.4918644428253174\n",
      "epoch391, loss 0.4916470944881439\n",
      "epoch392, loss 0.49142998456954956\n",
      "epoch393, loss 0.49121302366256714\n",
      "epoch394, loss 0.49099621176719666\n",
      "epoch395, loss 0.4907795786857605\n",
      "epoch396, loss 0.4905630946159363\n",
      "epoch397, loss 0.49034690856933594\n",
      "epoch398, loss 0.490130752325058\n",
      "epoch399, loss 0.48991483449935913\n",
      "epoch400, loss 0.4896990656852722\n",
      "epoch401, loss 0.4894835352897644\n",
      "epoch402, loss 0.48926812410354614\n",
      "epoch403, loss 0.4890528619289398\n",
      "epoch404, loss 0.4888378083705902\n",
      "epoch405, loss 0.48862290382385254\n",
      "epoch406, loss 0.48840823769569397\n",
      "epoch407, loss 0.48819366097450256\n",
      "epoch408, loss 0.48797932267189026\n",
      "epoch409, loss 0.4877651631832123\n",
      "epoch410, loss 0.48755115270614624\n",
      "epoch411, loss 0.48733729124069214\n",
      "epoch412, loss 0.48712363839149475\n",
      "epoch413, loss 0.4869101047515869\n",
      "epoch414, loss 0.4866968095302582\n",
      "epoch415, loss 0.486483633518219\n",
      "epoch416, loss 0.4862706661224365\n",
      "epoch417, loss 0.4860578179359436\n",
      "epoch418, loss 0.4858452379703522\n",
      "epoch419, loss 0.4856327176094055\n",
      "epoch420, loss 0.4854204058647156\n",
      "epoch421, loss 0.48520833253860474\n",
      "epoch422, loss 0.48499637842178345\n",
      "epoch423, loss 0.4847845435142517\n",
      "epoch424, loss 0.4845729470252991\n",
      "epoch425, loss 0.484361469745636\n",
      "epoch426, loss 0.4841501712799072\n",
      "epoch427, loss 0.4839390814304352\n",
      "epoch428, loss 0.48372817039489746\n",
      "epoch429, loss 0.4835173487663269\n",
      "epoch430, loss 0.48330679535865784\n",
      "epoch431, loss 0.4830963611602783\n",
      "epoch432, loss 0.4828861355781555\n",
      "epoch433, loss 0.4826759696006775\n",
      "epoch434, loss 0.48246604204177856\n",
      "epoch435, loss 0.48225632309913635\n",
      "epoch436, loss 0.4820467531681061\n",
      "epoch437, loss 0.48183727264404297\n",
      "epoch438, loss 0.48162803053855896\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch439, loss 0.48141899704933167\n",
      "epoch440, loss 0.48121005296707153\n",
      "epoch441, loss 0.4810013175010681\n",
      "epoch442, loss 0.48079270124435425\n",
      "epoch443, loss 0.4805842936038971\n",
      "epoch444, loss 0.48037606477737427\n",
      "epoch445, loss 0.480167955160141\n",
      "epoch446, loss 0.47996005415916443\n",
      "epoch447, loss 0.4797523021697998\n",
      "epoch448, loss 0.4795447289943695\n",
      "epoch449, loss 0.47933727502822876\n",
      "epoch450, loss 0.4791300296783447\n",
      "epoch451, loss 0.47892293334007263\n",
      "epoch452, loss 0.47871604561805725\n",
      "epoch453, loss 0.4785092771053314\n",
      "epoch454, loss 0.47830265760421753\n",
      "epoch455, loss 0.4780963063240051\n",
      "epoch456, loss 0.4778900146484375\n",
      "epoch457, loss 0.4776838719844818\n",
      "epoch458, loss 0.4774779677391052\n",
      "epoch459, loss 0.47727227210998535\n",
      "epoch460, loss 0.47706660628318787\n",
      "epoch461, loss 0.4768611490726471\n",
      "epoch462, loss 0.47665587067604065\n",
      "epoch463, loss 0.47645077109336853\n",
      "epoch464, loss 0.47624582052230835\n",
      "epoch465, loss 0.4760410189628601\n",
      "epoch466, loss 0.4758364260196686\n",
      "epoch467, loss 0.4756319522857666\n",
      "epoch468, loss 0.47542768716812134\n",
      "epoch469, loss 0.4752235412597656\n",
      "epoch470, loss 0.4750196039676666\n",
      "epoch471, loss 0.4748157858848572\n",
      "epoch472, loss 0.4746120870113373\n",
      "epoch473, loss 0.47440868616104126\n",
      "epoch474, loss 0.4742053151130676\n",
      "epoch475, loss 0.4740021824836731\n",
      "epoch476, loss 0.4737991690635681\n",
      "epoch477, loss 0.47359633445739746\n",
      "epoch478, loss 0.47339367866516113\n",
      "epoch479, loss 0.47319111227989197\n",
      "epoch480, loss 0.4729887843132019\n",
      "epoch481, loss 0.4727865755558014\n",
      "epoch482, loss 0.4725845754146576\n",
      "epoch483, loss 0.47238272428512573\n",
      "epoch484, loss 0.4721810221672058\n",
      "epoch485, loss 0.4719794690608978\n",
      "epoch486, loss 0.4717780649662018\n",
      "epoch487, loss 0.47157683968544006\n",
      "epoch488, loss 0.47137579321861267\n",
      "epoch489, loss 0.47117486596107483\n",
      "epoch490, loss 0.4709741175174713\n",
      "epoch491, loss 0.4707735478878021\n",
      "epoch492, loss 0.4705731272697449\n",
      "epoch493, loss 0.4703728258609772\n",
      "epoch494, loss 0.4701727032661438\n",
      "epoch495, loss 0.46997278928756714\n",
      "epoch496, loss 0.46977296471595764\n",
      "epoch497, loss 0.46957331895828247\n",
      "epoch498, loss 0.4693738520145416\n",
      "epoch499, loss 0.46917447447776794\n",
      "epoch500, loss 0.46897539496421814\n",
      "epoch501, loss 0.4687763750553131\n",
      "epoch502, loss 0.46857747435569763\n",
      "epoch503, loss 0.46837878227233887\n",
      "epoch504, loss 0.46818026900291443\n",
      "epoch505, loss 0.46798187494277954\n",
      "epoch506, loss 0.46778368949890137\n",
      "epoch507, loss 0.46758562326431274\n",
      "epoch508, loss 0.46738767623901367\n",
      "epoch509, loss 0.4671899378299713\n",
      "epoch510, loss 0.4669923186302185\n",
      "epoch511, loss 0.4667948782444\n",
      "epoch512, loss 0.46659761667251587\n",
      "epoch513, loss 0.46640053391456604\n",
      "epoch514, loss 0.466203510761261\n",
      "epoch515, loss 0.46600666642189026\n",
      "epoch516, loss 0.46580997109413147\n",
      "epoch517, loss 0.46561354398727417\n",
      "epoch518, loss 0.46541714668273926\n",
      "epoch519, loss 0.46522098779678345\n",
      "epoch520, loss 0.4650248885154724\n",
      "epoch521, loss 0.4648290276527405\n",
      "epoch522, loss 0.4646333158016205\n",
      "epoch523, loss 0.46443772315979004\n",
      "epoch524, loss 0.46424227952957153\n",
      "epoch525, loss 0.46404701471328735\n",
      "epoch526, loss 0.4638518691062927\n",
      "epoch527, loss 0.4636569619178772\n",
      "epoch528, loss 0.46346211433410645\n",
      "epoch529, loss 0.4632674753665924\n",
      "epoch530, loss 0.4630729556083679\n",
      "epoch531, loss 0.46287861466407776\n",
      "epoch532, loss 0.46268439292907715\n",
      "epoch533, loss 0.46249037981033325\n",
      "epoch534, loss 0.46229642629623413\n",
      "epoch535, loss 0.4621027112007141\n",
      "epoch536, loss 0.46190911531448364\n",
      "epoch537, loss 0.4617156982421875\n",
      "epoch538, loss 0.4615224301815033\n",
      "epoch539, loss 0.46132922172546387\n",
      "epoch540, loss 0.4611362814903259\n",
      "epoch541, loss 0.46094346046447754\n",
      "epoch542, loss 0.4607508182525635\n",
      "epoch543, loss 0.4605582654476166\n",
      "epoch544, loss 0.46036583185195923\n",
      "epoch545, loss 0.46017369627952576\n",
      "epoch546, loss 0.4599815309047699\n",
      "epoch547, loss 0.4597896635532379\n",
      "epoch548, loss 0.4595978260040283\n",
      "epoch549, loss 0.4594062864780426\n",
      "epoch550, loss 0.4592147767543793\n",
      "epoch551, loss 0.4590234160423279\n",
      "epoch552, loss 0.458832323551178\n",
      "epoch553, loss 0.45864129066467285\n",
      "epoch554, loss 0.4584503769874573\n",
      "epoch555, loss 0.4582596719264984\n",
      "epoch556, loss 0.4580690860748291\n",
      "epoch557, loss 0.45787858963012695\n",
      "epoch558, loss 0.4576883912086487\n",
      "epoch559, loss 0.4574982225894928\n",
      "epoch560, loss 0.45730823278427124\n",
      "epoch561, loss 0.457118421792984\n",
      "epoch562, loss 0.45692873001098633\n",
      "epoch563, loss 0.4567391872406006\n",
      "epoch564, loss 0.456549733877182\n",
      "epoch565, loss 0.4563605785369873\n",
      "epoch566, loss 0.456171452999115\n",
      "epoch567, loss 0.4559825360774994\n",
      "epoch568, loss 0.45579370856285095\n",
      "epoch569, loss 0.45560508966445923\n",
      "epoch570, loss 0.45541658997535706\n",
      "epoch571, loss 0.4552282392978668\n",
      "epoch572, loss 0.45503997802734375\n",
      "epoch573, loss 0.4548519253730774\n",
      "epoch574, loss 0.4546639919281006\n",
      "epoch575, loss 0.4544762074947357\n",
      "epoch576, loss 0.45428863167762756\n",
      "epoch577, loss 0.45410117506980896\n",
      "epoch578, loss 0.4539138376712799\n",
      "epoch579, loss 0.453726589679718\n",
      "epoch580, loss 0.4535396099090576\n",
      "epoch581, loss 0.453352689743042\n",
      "epoch582, loss 0.4531659483909607\n",
      "epoch583, loss 0.4529793858528137\n",
      "epoch584, loss 0.4527928829193115\n",
      "epoch585, loss 0.45260652899742126\n",
      "epoch586, loss 0.4524203836917877\n",
      "epoch587, loss 0.4522344172000885\n",
      "epoch588, loss 0.45204854011535645\n",
      "epoch589, loss 0.45186275243759155\n",
      "epoch590, loss 0.4516771733760834\n",
      "epoch591, loss 0.45149174332618713\n",
      "epoch592, loss 0.45130643248558044\n",
      "epoch593, loss 0.4511212706565857\n",
      "epoch594, loss 0.4509362578392029\n",
      "epoch595, loss 0.4507514536380768\n",
      "epoch596, loss 0.45056667923927307\n",
      "epoch597, loss 0.4503820538520813\n",
      "epoch598, loss 0.45019760727882385\n",
      "epoch599, loss 0.45001330971717834\n",
      "epoch600, loss 0.44982919096946716\n",
      "epoch601, loss 0.44964513182640076\n",
      "epoch602, loss 0.44946128129959106\n",
      "epoch603, loss 0.4492775797843933\n",
      "epoch604, loss 0.4490939676761627\n",
      "epoch605, loss 0.44891053438186646\n",
      "epoch606, loss 0.44872722029685974\n",
      "epoch607, loss 0.44854408502578735\n",
      "epoch608, loss 0.4483610689640045\n",
      "epoch609, loss 0.4481782019138336\n",
      "epoch610, loss 0.4479954242706299\n",
      "epoch611, loss 0.44781285524368286\n",
      "epoch612, loss 0.4476304054260254\n",
      "epoch613, loss 0.44744807481765747\n",
      "epoch614, loss 0.4472659230232239\n",
      "epoch615, loss 0.44708389043807983\n",
      "epoch616, loss 0.44690194725990295\n",
      "epoch617, loss 0.4467202126979828\n",
      "epoch618, loss 0.44653862714767456\n",
      "epoch619, loss 0.44635719060897827\n",
      "epoch620, loss 0.44617587327957153\n",
      "epoch621, loss 0.44599467515945435\n",
      "epoch622, loss 0.4458135664463043\n",
      "epoch623, loss 0.4456326961517334\n",
      "epoch624, loss 0.44545191526412964\n",
      "epoch625, loss 0.44527125358581543\n",
      "epoch626, loss 0.44509077072143555\n",
      "epoch627, loss 0.4449104368686676\n",
      "epoch628, loss 0.4447302222251892\n",
      "epoch629, loss 0.44455012679100037\n",
      "epoch630, loss 0.44437021017074585\n",
      "epoch631, loss 0.4441904127597809\n",
      "epoch632, loss 0.44401073455810547\n",
      "epoch633, loss 0.44383126497268677\n",
      "epoch634, loss 0.44365182518959045\n",
      "epoch635, loss 0.44347256422042847\n",
      "epoch636, loss 0.4432934820652008\n",
      "epoch637, loss 0.4431145191192627\n",
      "epoch638, loss 0.4429357051849365\n",
      "epoch639, loss 0.4427569806575775\n",
      "epoch640, loss 0.44257840514183044\n",
      "epoch641, loss 0.4424000382423401\n",
      "epoch642, loss 0.4422217309474945\n",
      "epoch643, loss 0.44204360246658325\n",
      "epoch644, loss 0.44186559319496155\n",
      "epoch645, loss 0.4416877329349518\n",
      "epoch646, loss 0.4415099024772644\n",
      "epoch647, loss 0.4413323998451233\n",
      "epoch648, loss 0.4411548972129822\n",
      "epoch649, loss 0.4409775733947754\n",
      "epoch650, loss 0.44080036878585815\n",
      "epoch651, loss 0.44062328338623047\n",
      "epoch652, loss 0.4404463768005371\n",
      "epoch653, loss 0.4402696192264557\n",
      "epoch654, loss 0.44009295105934143\n",
      "epoch655, loss 0.4399164319038391\n",
      "epoch656, loss 0.43974003195762634\n",
      "epoch657, loss 0.4395638108253479\n",
      "epoch658, loss 0.439387708902359\n",
      "epoch659, loss 0.4392116963863373\n",
      "epoch660, loss 0.43903589248657227\n",
      "epoch661, loss 0.4388601779937744\n",
      "epoch662, loss 0.4386846125125885\n",
      "epoch663, loss 0.43850916624069214\n",
      "epoch664, loss 0.4383338391780853\n",
      "epoch665, loss 0.43815869092941284\n",
      "epoch666, loss 0.4379836916923523\n",
      "epoch667, loss 0.43780869245529175\n",
      "epoch668, loss 0.4376339912414551\n",
      "epoch669, loss 0.4374592900276184\n",
      "epoch670, loss 0.4372848570346832\n",
      "epoch671, loss 0.4371105134487152\n",
      "epoch672, loss 0.4369361996650696\n",
      "epoch673, loss 0.43676209449768066\n",
      "epoch674, loss 0.4365881085395813\n",
      "epoch675, loss 0.43641433119773865\n",
      "epoch676, loss 0.43624061346054077\n",
      "epoch677, loss 0.43606704473495483\n",
      "epoch678, loss 0.43589362502098083\n",
      "epoch679, loss 0.4357203543186188\n",
      "epoch680, loss 0.4355471730232239\n",
      "epoch681, loss 0.43537408113479614\n",
      "epoch682, loss 0.4352012276649475\n",
      "epoch683, loss 0.4350283741950989\n",
      "epoch684, loss 0.43485575914382935\n",
      "epoch685, loss 0.43468326330184937\n",
      "epoch686, loss 0.43451085686683655\n",
      "epoch687, loss 0.4343385696411133\n",
      "epoch688, loss 0.43416649103164673\n",
      "epoch689, loss 0.43399447202682495\n",
      "epoch690, loss 0.4338225722312927\n",
      "epoch691, loss 0.4336508810520172\n",
      "epoch692, loss 0.4334792494773865\n",
      "epoch693, loss 0.43330782651901245\n",
      "epoch694, loss 0.4331364035606384\n",
      "epoch695, loss 0.4329652190208435\n",
      "epoch696, loss 0.43279415369033813\n",
      "epoch697, loss 0.4326232075691223\n",
      "epoch698, loss 0.43245235085487366\n",
      "epoch699, loss 0.4322816729545593\n",
      "epoch700, loss 0.43211111426353455\n",
      "epoch701, loss 0.43194064497947693\n",
      "epoch702, loss 0.431770384311676\n",
      "epoch703, loss 0.4316001534461975\n",
      "epoch704, loss 0.4314301609992981\n",
      "epoch705, loss 0.43126019835472107\n",
      "epoch706, loss 0.43109041452407837\n",
      "epoch707, loss 0.4309207797050476\n",
      "epoch708, loss 0.430751234292984\n",
      "epoch709, loss 0.43058186769485474\n",
      "epoch710, loss 0.4304125905036926\n",
      "epoch711, loss 0.4302434027194977\n",
      "epoch712, loss 0.43007439374923706\n",
      "epoch713, loss 0.429905503988266\n",
      "epoch714, loss 0.42973676323890686\n",
      "epoch715, loss 0.4295681118965149\n",
      "epoch716, loss 0.4293995797634125\n",
      "epoch717, loss 0.4292312264442444\n",
      "epoch718, loss 0.4290629029273987\n",
      "epoch719, loss 0.4288948178291321\n",
      "epoch720, loss 0.42872676253318787\n",
      "epoch721, loss 0.428558886051178\n",
      "epoch722, loss 0.42839115858078003\n",
      "epoch723, loss 0.42822352051734924\n",
      "epoch724, loss 0.4280560612678528\n",
      "epoch725, loss 0.4278886914253235\n",
      "epoch726, loss 0.42772141098976135\n",
      "epoch727, loss 0.42755427956581116\n",
      "epoch728, loss 0.4273872971534729\n",
      "epoch729, loss 0.4272204339504242\n",
      "epoch730, loss 0.4270537495613098\n",
      "epoch731, loss 0.4268870949745178\n",
      "epoch732, loss 0.426720529794693\n",
      "epoch733, loss 0.42655426263809204\n",
      "epoch734, loss 0.4263879656791687\n",
      "epoch735, loss 0.4262217879295349\n",
      "epoch736, loss 0.4260558485984802\n",
      "epoch737, loss 0.4258899688720703\n",
      "epoch738, loss 0.4257242679595947\n",
      "epoch739, loss 0.4255586266517639\n",
      "epoch740, loss 0.4253931939601898\n",
      "epoch741, loss 0.42522773146629333\n",
      "epoch742, loss 0.42506250739097595\n",
      "epoch743, loss 0.42489734292030334\n",
      "epoch744, loss 0.42473235726356506\n",
      "epoch745, loss 0.4245675206184387\n",
      "epoch746, loss 0.42440277338027954\n",
      "epoch747, loss 0.4242381155490875\n",
      "epoch748, loss 0.42407360672950745\n",
      "epoch749, loss 0.4239092767238617\n",
      "epoch750, loss 0.4237450063228607\n",
      "epoch751, loss 0.4235808849334717\n",
      "epoch752, loss 0.42341679334640503\n",
      "epoch753, loss 0.42325296998023987\n",
      "epoch754, loss 0.4230891764163971\n",
      "epoch755, loss 0.42292556166648865\n",
      "epoch756, loss 0.42276206612586975\n",
      "epoch757, loss 0.4225986897945404\n",
      "epoch758, loss 0.42243537306785583\n",
      "epoch759, loss 0.4222722053527832\n",
      "epoch760, loss 0.4221091866493225\n",
      "epoch761, loss 0.4219462275505066\n",
      "epoch762, loss 0.421783447265625\n",
      "epoch763, loss 0.42162078619003296\n",
      "epoch764, loss 0.42145824432373047\n",
      "epoch765, loss 0.42129582166671753\n",
      "epoch766, loss 0.42113351821899414\n",
      "epoch767, loss 0.4209713339805603\n",
      "epoch768, loss 0.420809268951416\n",
      "epoch769, loss 0.4206473231315613\n",
      "epoch770, loss 0.4204854965209961\n",
      "epoch771, loss 0.42032378911972046\n",
      "epoch772, loss 0.4201622009277344\n",
      "epoch773, loss 0.4200007915496826\n",
      "epoch774, loss 0.419839471578598\n",
      "epoch775, loss 0.4196782112121582\n",
      "epoch776, loss 0.4195171296596527\n",
      "epoch777, loss 0.41935616731643677\n",
      "epoch778, loss 0.4191953241825104\n",
      "epoch779, loss 0.41903454065322876\n",
      "epoch780, loss 0.41887393593788147\n",
      "epoch781, loss 0.41871339082717896\n",
      "epoch782, loss 0.41855305433273315\n",
      "epoch783, loss 0.4183928072452545\n",
      "epoch784, loss 0.41823267936706543\n",
      "epoch785, loss 0.4180726408958435\n",
      "epoch786, loss 0.41791272163391113\n",
      "epoch787, loss 0.4177529215812683\n",
      "epoch788, loss 0.4175933003425598\n",
      "epoch789, loss 0.4174337387084961\n",
      "epoch790, loss 0.4172743260860443\n",
      "epoch791, loss 0.4171150326728821\n",
      "epoch792, loss 0.4169557988643646\n",
      "epoch793, loss 0.4167967438697815\n",
      "epoch794, loss 0.41663774847984314\n",
      "epoch795, loss 0.4164789319038391\n",
      "epoch796, loss 0.41632023453712463\n",
      "epoch797, loss 0.41616159677505493\n",
      "epoch798, loss 0.4160030782222748\n",
      "epoch799, loss 0.41584476828575134\n",
      "epoch800, loss 0.4156865179538727\n",
      "epoch801, loss 0.41552838683128357\n",
      "epoch802, loss 0.41537031531333923\n",
      "epoch803, loss 0.4152124524116516\n",
      "epoch804, loss 0.41505464911460876\n",
      "epoch805, loss 0.41489702463150024\n",
      "epoch806, loss 0.4147394299507141\n",
      "epoch807, loss 0.4145820140838623\n",
      "epoch808, loss 0.41442471742630005\n",
      "epoch809, loss 0.41426748037338257\n",
      "epoch810, loss 0.4141104221343994\n",
      "epoch811, loss 0.41395339369773865\n",
      "epoch812, loss 0.4137965738773346\n",
      "epoch813, loss 0.4136398732662201\n",
      "epoch814, loss 0.4134831428527832\n",
      "epoch815, loss 0.4133267402648926\n",
      "epoch816, loss 0.4131702780723572\n",
      "epoch817, loss 0.4130140244960785\n",
      "epoch818, loss 0.41285786032676697\n",
      "epoch819, loss 0.4127018451690674\n",
      "epoch820, loss 0.41254591941833496\n",
      "epoch821, loss 0.4123900532722473\n",
      "epoch822, loss 0.4122343957424164\n",
      "epoch823, loss 0.4120787978172302\n",
      "epoch824, loss 0.4119233191013336\n",
      "epoch825, loss 0.41176801919937134\n",
      "epoch826, loss 0.41161274909973145\n",
      "epoch827, loss 0.41145753860473633\n",
      "epoch828, loss 0.41130250692367554\n",
      "epoch829, loss 0.41114768385887146\n",
      "epoch830, loss 0.41099292039871216\n",
      "epoch831, loss 0.41083818674087524\n",
      "epoch832, loss 0.41068363189697266\n",
      "epoch833, loss 0.4105291962623596\n",
      "epoch834, loss 0.41037482023239136\n",
      "epoch835, loss 0.4102206826210022\n",
      "epoch836, loss 0.41006654500961304\n",
      "epoch837, loss 0.4099125266075134\n",
      "epoch838, loss 0.40975871682167053\n",
      "epoch839, loss 0.40960493683815\n",
      "epoch840, loss 0.4094512462615967\n",
      "epoch841, loss 0.4092977046966553\n",
      "epoch842, loss 0.40914425253868103\n",
      "epoch843, loss 0.40899091958999634\n",
      "epoch844, loss 0.40883779525756836\n",
      "epoch845, loss 0.4086846709251404\n",
      "epoch846, loss 0.40853166580200195\n",
      "epoch847, loss 0.40837883949279785\n",
      "epoch848, loss 0.4082260727882385\n",
      "epoch849, loss 0.40807342529296875\n",
      "epoch850, loss 0.4079208970069885\n",
      "epoch851, loss 0.40776848793029785\n",
      "epoch852, loss 0.40761613845825195\n",
      "epoch853, loss 0.407463937997818\n",
      "epoch854, loss 0.4073118567466736\n",
      "epoch855, loss 0.4071598947048187\n",
      "epoch856, loss 0.40700802206993103\n",
      "epoch857, loss 0.4068562984466553\n",
      "epoch858, loss 0.4067046046257019\n",
      "epoch859, loss 0.40655308961868286\n",
      "epoch860, loss 0.4064016342163086\n",
      "epoch861, loss 0.40625032782554626\n",
      "epoch862, loss 0.4060991406440735\n",
      "epoch863, loss 0.40594807267189026\n",
      "epoch864, loss 0.4057970643043518\n",
      "epoch865, loss 0.4056462347507477\n",
      "epoch866, loss 0.40549546480178833\n",
      "epoch867, loss 0.40534478425979614\n",
      "epoch868, loss 0.4051942229270935\n",
      "epoch869, loss 0.4050437808036804\n",
      "epoch870, loss 0.4048934876918793\n",
      "epoch871, loss 0.4047432839870453\n",
      "epoch872, loss 0.40459316968917847\n",
      "epoch873, loss 0.4044432044029236\n",
      "epoch874, loss 0.4042932987213135\n",
      "epoch875, loss 0.4041435122489929\n",
      "epoch876, loss 0.4039938449859619\n",
      "epoch877, loss 0.40384426712989807\n",
      "epoch878, loss 0.40369486808776855\n",
      "epoch879, loss 0.4035455584526062\n",
      "epoch880, loss 0.40339627861976624\n",
      "epoch881, loss 0.4032471776008606\n",
      "epoch882, loss 0.4030981659889221\n",
      "epoch883, loss 0.4029492735862732\n",
      "epoch884, loss 0.40280041098594666\n",
      "epoch885, loss 0.40265172719955444\n",
      "epoch886, loss 0.4025031626224518\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch887, loss 0.4023546576499939\n",
      "epoch888, loss 0.40220627188682556\n",
      "epoch889, loss 0.40205803513526917\n",
      "epoch890, loss 0.40190988779067993\n",
      "epoch891, loss 0.40176185965538025\n",
      "epoch892, loss 0.40161386132240295\n",
      "epoch893, loss 0.40146604180336\n",
      "epoch894, loss 0.4013182520866394\n",
      "epoch895, loss 0.40117067098617554\n",
      "epoch896, loss 0.4010232090950012\n",
      "epoch897, loss 0.4008758068084717\n",
      "epoch898, loss 0.4007285237312317\n",
      "epoch899, loss 0.4005813002586365\n",
      "epoch900, loss 0.4004341959953308\n",
      "epoch901, loss 0.4002872407436371\n",
      "epoch902, loss 0.4001403748989105\n",
      "epoch903, loss 0.3999935984611511\n",
      "epoch904, loss 0.39984697103500366\n",
      "epoch905, loss 0.3997003436088562\n",
      "epoch906, loss 0.39955395460128784\n",
      "epoch907, loss 0.3994075655937195\n",
      "epoch908, loss 0.39926132559776306\n",
      "epoch909, loss 0.3991152048110962\n",
      "epoch910, loss 0.39896923303604126\n",
      "epoch911, loss 0.39882326126098633\n",
      "epoch912, loss 0.3986774682998657\n",
      "epoch913, loss 0.3985317349433899\n",
      "epoch914, loss 0.3983860909938812\n",
      "epoch915, loss 0.3982405960559845\n",
      "epoch916, loss 0.39809519052505493\n",
      "epoch917, loss 0.3979499340057373\n",
      "epoch918, loss 0.39780476689338684\n",
      "epoch919, loss 0.39765962958335876\n",
      "epoch920, loss 0.3975147008895874\n",
      "epoch921, loss 0.3973698019981384\n",
      "epoch922, loss 0.397225022315979\n",
      "epoch923, loss 0.39708036184310913\n",
      "epoch924, loss 0.3969357907772064\n",
      "epoch925, loss 0.39679139852523804\n",
      "epoch926, loss 0.39664700627326965\n",
      "epoch927, loss 0.39650270342826843\n",
      "epoch928, loss 0.3963586091995239\n",
      "epoch929, loss 0.3962145447731018\n",
      "epoch930, loss 0.39607059955596924\n",
      "epoch931, loss 0.3959267735481262\n",
      "epoch932, loss 0.395783007144928\n",
      "epoch933, loss 0.3956393599510193\n",
      "epoch934, loss 0.39549586176872253\n",
      "epoch935, loss 0.39535245299339294\n",
      "epoch936, loss 0.3952091336250305\n",
      "epoch937, loss 0.39506590366363525\n",
      "epoch938, loss 0.39492279291152954\n",
      "epoch939, loss 0.3947798013687134\n",
      "epoch940, loss 0.3946368396282196\n",
      "epoch941, loss 0.3944939970970154\n",
      "epoch942, loss 0.3943513035774231\n",
      "epoch943, loss 0.39420872926712036\n",
      "epoch944, loss 0.3940662443637848\n",
      "epoch945, loss 0.393923819065094\n",
      "epoch946, loss 0.39378154277801514\n",
      "epoch947, loss 0.3936392664909363\n",
      "epoch948, loss 0.39349719882011414\n",
      "epoch949, loss 0.39335522055625916\n",
      "epoch950, loss 0.39321333169937134\n",
      "epoch951, loss 0.3930715322494507\n",
      "epoch952, loss 0.3929298520088196\n",
      "epoch953, loss 0.392788290977478\n",
      "epoch954, loss 0.39264675974845886\n",
      "epoch955, loss 0.39250537753105164\n",
      "epoch956, loss 0.3923640847206116\n",
      "epoch957, loss 0.39222291111946106\n",
      "epoch958, loss 0.3920818269252777\n",
      "epoch959, loss 0.3919408321380615\n",
      "epoch960, loss 0.3917998969554901\n",
      "epoch961, loss 0.3916591703891754\n",
      "epoch962, loss 0.3915184438228607\n",
      "epoch963, loss 0.39137786626815796\n",
      "epoch964, loss 0.39123740792274475\n",
      "epoch965, loss 0.3910970091819763\n",
      "epoch966, loss 0.39095669984817505\n",
      "epoch967, loss 0.3908165395259857\n",
      "epoch968, loss 0.39067643880844116\n",
      "epoch969, loss 0.39053645730018616\n",
      "epoch970, loss 0.3903965950012207\n",
      "epoch971, loss 0.3902568221092224\n",
      "epoch972, loss 0.3901171088218689\n",
      "epoch973, loss 0.38997748494148254\n",
      "epoch974, loss 0.3898380398750305\n",
      "epoch975, loss 0.3896985948085785\n",
      "epoch976, loss 0.3895593285560608\n",
      "epoch977, loss 0.38942012190818787\n",
      "epoch978, loss 0.3892810344696045\n",
      "epoch979, loss 0.3891420066356659\n",
      "epoch980, loss 0.3890031576156616\n",
      "epoch981, loss 0.38886433839797974\n",
      "epoch982, loss 0.3887256681919098\n",
      "epoch983, loss 0.38858702778816223\n",
      "epoch984, loss 0.38844847679138184\n",
      "epoch985, loss 0.38831013441085815\n",
      "epoch986, loss 0.38817182183265686\n",
      "epoch987, loss 0.38803356885910034\n",
      "epoch988, loss 0.38789546489715576\n",
      "epoch989, loss 0.38775745034217834\n",
      "epoch990, loss 0.3876195549964905\n",
      "epoch991, loss 0.3874817490577698\n",
      "epoch992, loss 0.38734397292137146\n",
      "epoch993, loss 0.38720637559890747\n",
      "epoch994, loss 0.38706886768341064\n",
      "epoch995, loss 0.3869313895702362\n",
      "epoch996, loss 0.3867940902709961\n",
      "epoch997, loss 0.386656790971756\n",
      "epoch998, loss 0.38651973009109497\n",
      "epoch999, loss 0.38638266921043396\n"
     ]
    }
   ],
   "source": [
    "epochs = 1000 \n",
    "for epoch in range(epochs):\n",
    "    inputs, labels = x_train, y_train   \n",
    "    out = model(inputs)    \n",
    "    optimiser.zero_grad()    \n",
    "    loss = criterion(out, labels)    \n",
    "    loss.backward()    \n",
    "    optimiser.step()\n",
    "    predicted = model.forward(x_train)    \n",
    "    print('epoch{}, loss {}'.format(epoch, loss.item()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "OrderedDict([('linear.weight', tensor([[ 0.6929]])), ('linear.bias', tensor([-1.7570]))])\n"
     ]
    }
   ],
   "source": [
    "print(model.state_dict())\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tensor([ 0.1561]) false\n",
      "tensor([ 0.3279]) false\n",
      "tensor([ 0.4592]) false\n",
      "tensor([ 0.5797]) true\n",
      "tensor([ 0.9357]) true\n"
     ]
    }
   ],
   "source": [
    "test=torch.tensor([[0.1],[1.5],[2.3],[3.0],[6.4]])\n",
    "results = model(test)\n",
    "for result in results:\n",
    "    if result <= 0.5:\n",
    "        print(result,'false')\n",
    "    else: print(result, 'true')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Threshold(\n",
       "  threshold=tensor([-3.0000, -2.7895, -2.5789, -2.3684, -2.1579, -1.9474, -1.7368,\n",
       "          -1.5263, -1.3158, -1.1053, -0.8947, -0.6842, -0.4737, -0.2632,\n",
       "          -0.0526,  0.1579,  0.3684,  0.5789,  0.7895,  1.0000]), value=0\n",
       ")"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nn.Threshold(xin,0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
